package com.server.transaction.handler;

import lombok.extern.slf4j.Slf4j;

/**
 * @author gyuan
 * @date 2023/9/19 9:24
 * @description 线程异步执行时 也可以进行日志打印的处理类
 */
@Slf4j
public class GlobalUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler {

    private static final GlobalUncaughtExceptionHandler instance = new GlobalUncaughtExceptionHandler();

    @Override
    public void uncaughtException(Thread t, Throwable e) {
        log.error("Exception in thread {} ", t.getName(), e);
    }

    public static GlobalUncaughtExceptionHandler getInstance() {
        return instance;
    }

}
